<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html class="  ext-strict x-viewport">
<head>
<title>后台登录界面</title>
<meta content="text/html; charset=UTF-8" http-equiv="Content-Type">
<link rel="stylesheet" href='<?php echo $static_url; ?>common/css/admin.css' type="text/css" />
<script src="<?php echo $static_url; ?>common/js/jquery-1.8.3.min.js" type="text/javascript"></script>
</head>
<body class="body_background">
	<div class="form_container">
		<form name="" action="" method="post">
			<div class="go-app-logo"></div>
			<div class="x-form-item" ><label class="form_lable">用户名:</label><input type="text" name="username" class="x-form-input" id="username"/><span></span></div>
			<div class="x-form-item"><label class="form_lable">密码:</label><input type="password" name="password" class="x-form-input" id="password"/></div>
			<div class="x-form-item"><input type="checkbox" class="remind" id="ext-comp-1012" /><label for="ext-comp-1012" class="x-form-cb-label">在此计算机上保存我的信息</label></div>
			<div class="x-form-item">
				<div style="float:left;color:#f00;display:none;" id="error_div"></div>
				<div class="x-form-right">
					<button type="button" id="ext-gen19" class=" x-btn-text">忘记密码？</button>
					<button onclick="login()" type="button" id="ext-gen21" class=" x-btn-text">确定</button>
				</div>
			</div>
		</form>
	</div>

<script type="text/javascript">
//监控回车键
$(function(){
	$("#username").focus();
	$('input').keydown(function(aevent){
		aevent = aevent||window.event;
		if( aevent.keyCode == 13 ) {
			login();
		}
	});
});

//登录
function login(){
	var username = $("#username").val();
	var password = $("#password").val();
	var error_div = $("#error_div");
	var error_text = "";
	var remind = 1;
	if( username == '' || password == '' ){
		error_text = "用户名或密码不能为空";
		error_div.html(error_text).show();
		return;
	}
	if( $(".remind").prop("checked") == true ){
		remind = 2;
	}
	$.ajax({
		url: "/admin/user/do/do_login.php",
		type: "POST",
		cache: false,
		data: {"username":username,"password":password,"remind":remind},
		dataType: "json",
		beforeSend: function(){
			error_text = "登录中...";
			error_div.html(error_text).show();
		},
		success: function(msg){
			if( msg.status !== false ){
				error_div.html("").hide();
				window.location.href = "/www/admin/index.php";
			}else{
				error_text = "用户名或密码错误";
				error_div.html(error_text).show();
			}
		},
		timeout: 10000,
		error: function(XMLHttpRequest, textStatus){
			if( textStatus ){
				error_text = "登录出错，请重试";
				error_div.html(error_text).show();
			}
		}
	});
}
</script>
</body>
</html>